package cc.zy.base.hr.service.impl;

import cc.zy.base.common.entity.FebsConstant;
import cc.zy.base.common.entity.QueryRequest;
import cc.zy.base.common.utils.SortUtil;
import cc.zy.base.hr.entity.Course;
import cc.zy.base.hr.entity.ExecuteSchedule;

import cc.zy.base.hr.mapper.ExecuteScheduleMapper;

import cc.zy.base.hr.service.IExecuteScheduleService;

import com.baomidou.mybatisplus.core.metadata.IPage;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * 月计划执行
 * Service
 * @author yan
 * @date 2021-01-18 10:51:13
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class ExecuteScheduleServiceImpl extends ServiceImpl<ExecuteScheduleMapper, ExecuteSchedule> implements IExecuteScheduleService {

    @Resource
    private final ExecuteScheduleMapper executeScheduleMapper;

    @Override
    public IPage<ExecuteSchedule> findExecuteScheduleByPage(QueryRequest request, ExecuteSchedule schedule) {
        Page<ExecuteSchedule> page = new Page<>(request.getPageNum(), request.getPageSize());
        page.setSearchCount(false);
        page.setTotal(baseMapper.executeScheduleCount());
        SortUtil.handlePageSort(request, page, "id", FebsConstant.ORDER_ASC, false);
        return baseMapper.findScheduleDetailPage(page,schedule);
    }

    @Override
    public ExecuteSchedule findById(Integer id) {
        return baseMapper.findById(id);
    }

    @Override
    public void deleteExecuteSchedule(int id) {
        executeScheduleMapper.deleteExecuteSchedule(id);
    }

    @Override
    public long executeScheduleCount() {
        return executeScheduleMapper.executeScheduleCount();
    }

    @Override
    public List<Course> queryCourseName() {
        return executeScheduleMapper.queryCourseName();
    }

    @Override
    public void updatePlanDate(ExecuteSchedule executeSchedule) {
        executeScheduleMapper.updatePlanDate(executeSchedule);
    }


    @Override
    public List<ExecuteSchedule> findExecuteScheduleListNotPage(ExecuteSchedule executeSchedule) {
        return baseMapper.findExecuteScheduleListNotPage(executeSchedule);
    }
}